폼체크임당 :: PHP팁 게시판[SSISO Community]
 
SSISO 카페 SSISO Source SSISO 구직 SSISO 쇼핑몰 SSISO 맛집
추천검색어 : JUnit   Log4j   ajax   spring   struts   struts-config.xml   Synchronized   책정보   Ajax 마스터하기   우측부분

PHP팁 게시판
[1]
등록일:2007-11-21 23:56:25 (0%)
작성자:
제목:폼체크임당
                /**  
                *  make  by  BlueSys(푸른공허)  
                *  |jb0077|@|empal|.|com|  에서  |를  제거  하세요.  
                *  
                *  메시지  
                */  
                function  fncMessage()  {  
                        this.isAlert  =  true;  
                        this.message  =  "";  

                        this.get  =  _fncGetMessage;  
                        this.alert  =  _fncAlertMsg;  
                        this.setIsAlert  =  _fncIsAlert;  

                        return  this;  
                }  

                function  _fncIsAlert()  {  
                        this.isAlert  =  arguments[0];  
                }  

                function  _fncAlertMsg()  {  
                        if(this.isAlert)  {  
                                alert(arguments[0]);  
                        }  
                        return  this;  
                }  

                function  _fncGetMessage()  {  
                        /**  
                        *  ====================  Rulls  ====================  
                        *  1.  Message  [$n]형식은  사용할수  없습니다.  
                        *  ===============================================  
                        */  
                        this.messages  =  [];  
                        this.messages['MSG-0001']  =  "$0  입력하여  주십시오.";  
                        this.messages['MSG-0002']  =  "$0  체크하여  주십시오.";  
                        this.messages['MSG-0003']  =  "$0  $1  개  이상  선택  하실수  없습니다.";  
                        this.messages['MSG-0004']  =  "$0  $1  개  이상  $2  개  미만으로  선택하여  주십시오.";  
                        this.messages['MSG-0005']  =  "$0  선택하여  주십시오.";  

                        this.messages['MSG-0006']  =  "$0  숫자로만  작성되어야  합니다.";  
                        this.messages['MSG-0007']  =  "$0  영문자/숫자로만  작성되어야  합니다.";  
                        this.messages['MSG-0008']  =  "$0  $1  의형식으로  작성되어야  합니다.";  
                        this.messages['MSG-0009']  =  "올바른  형식의  $0  이(가)  아닙니다.";  

                        this.messages['MSG-0010']  =  "$0  $1  자리로  작성하여야  합니다.";  
                        this.messages['MSG-0011']  =  "$0  최소  $1  최대  $2  글자  미만으로  작성하여야  합니다.";  

                        this.messages['MSG-0012']  =  "$0  올바른  $1  아닙니다.";  
                        this.messages['MSG-0013']  =  "$0  $1  개  이상  선택  하실수  없습니다.";  
                        this.messages['MSG-0014']  =  "$0  오브젝트  Length보다  큽니다.";  

                        this.messages['MSG-0015']  =  "제한할  파일  확장자가  없습니다.";  
                        this.messages['MSG-0016']  =  "허용할  파일  확장자가  없습니다.";  
                        this.messages['MSG-0017']  =  "허용되지  않는  파일  입니다.";  

                        this.messages['MSG-0018']  =  "$0  영문자로만  작성되어야  합니다.";  

                        this.messages['MSG-0019']  =  "$0  특수문자를  사용하실수  없습니다.";  
                        this.messages['MSG-0020']  =  "$0  $1  이외의  특수문자는  사용하실수  없습니다.";  

                        this.messages['MSG-0021']  =  "$0  한글만  사용  가능  합니다.";  
                        this.messages['MSG-0022']  =  "$0  동일한  문자를  $1  자  이상  사용하실수  없습니다.";  

                        this.messages['MSG-0023']  =  "$0  연속된  문자열로  되어  있습니다.";  
                  
                        this.message  =  this.messages[arguments[0]];  
                  
                        if(arguments.length  >  1)  {  
                                for(var  x=1;  x<arguments.length;  x++)  {  
                                        this.message  =  this.message.replace("$"+(x-1)  ,  arguments[x]);  
                                }  
                        }  

                        return  this.message;  
                }  

                var  message  =  new  fncMessage();  

                /**  
                *  make  by  거친마루  
                *  한글  조사  
                */  
                String.prototype.hasFinalConsonant  =  function(str)  {  
                        str  =  this  !=  window  ?  this  :  str;  
                        var  strTemp  =  str.substr(str.length-1);  
                        return  ((strTemp.charCodeAt(0)-16)%28!=0);  
                }  

                function  josa(str,tail)  {  
                        return  (str.hasFinalConsonant())  ?  tail.substring(0,1)  :  tail.substring(1,2);  
                }  

                /**  
                *  make  by  BlueSys(푸른공허)  
                *  |jb0077|@|empal|.|com|  에서  |를  제거  하세요.  
                *  
                *  
                *  FText  
                *        isNull                        공백  체크  
                *        nullable                빈  값  허용  여부(nullable  이면  값이  없으면  통과,  있으면  체크한다.)  
                *                ====================================================  
                *                //  isNull  과  nullable은  같이  사용할수  없다.  
                *                ====================================================  
                *        isNumber                숫자만  허용                                (공백  허용  안함)  
                *        isKorean                한글만  허용                                (공백  허용  안함  ,  완성형만  입력가능)  
                *                                        예)  안녕하세요  -  허용  
                *                                                ㅋ,ㅎ,ㅇ    -  허용하지  않음  
                *        isKoreanNumeric        한글,숫자만  허용                (공백  허용  안함  ,  완성형만  입력가능)  
                *        isAlphabat                영문자만  허용                        (공백  허용  안함)  
                *        isAlphaNumeric        숫자,영문자만  허용                (공백  허용  안함)  
                *        isDuplication        문자의  중복  체크                (default  :  3자)  
                *                                                                @arguments[0]  허용하는  중복  갯수  
                *  
                *        limitSpcChar        특수문자  제한  체크  
                *                                                                @arguments[0]  허용할  특수  문자  
                *  
                *                        1.  specialChar()                                ::  특수  문자  입력  안됨  
                *                        2.  specialChar(",",  ".",  "^")        ::  작성된  특수  문자만  허용  함  
                *  
                *        isChainChar                문자의  연속성  체크                (default  ::  4자  이상의  연속된  문자열  체크)  
                *                                        예)  1234  ,  9876  ,  abcd  ,  1234abvc  
                *  
                *        range                        길이  체크  
                *                                                                @arguments[0]  최소  길이  
                *                                                                @arguments[1]  최대  길이  
                *        isMail                        메일  유효성  체크  
                *  
                *        isSsn                        input  폼이  1개  일  경우에만  사용  (onKeyup=fncSsnForm(this)  함수  사용)  
                *                                        간단한  주민번호  유효성  체크  (000000-0000000  의  형식으로  입력)  
                *        validation()  
                *  
                *        ==========================  사용법  ===================================================  
                *        if(!FForm(new  FText("텍스트"  ,  "textTest")  
                *                        .isNull().range(4,4).validation()))  return;  
                *        ==========================  사용법  ===================================================  
                *  
                *  FRadio  
                *        validation()        라디오의  checked  체크  
                *  
                *        ==========================  사용법  ===================================================  
                *        if(!FForm(new  FRadio("라디오"  ,  "radioTest")  
                *                        .validation()))  return;  
                *        ==========================  사용법  ===================================================  
                *  
                *  FCheck  
                *        setMulti                멀티  여부  (default  =  false;)  
                *                                                                @arguments[0]  true  |  false  
                *        range                        멀티  일  경우  선택  갯수  지정(default  =  1)  
                *                                                                @arguments[0]  선택  가능  한  갯수  
                *        validation()        체크  박스의  checked  체크  
                *  
                *        ==========================  사용법  ===================================================  
                *                                                                        선택  하였는지  체크,  (default  :  1개만  선택  가능)  
                *        if(!FForm(new  FCheck("체크박스"  ,  "checkboxTest")  
                *                        .validation()))  return;  
                *                                                                        선택  하였는지  체크,  (default  :  1개  이상  선택  가능)  
                *        if(!FForm(new  FCheck("체크박스"  ,  "checkboxTest")  
                *                        .setMulti(true).validation()))  return;  
                *                                                                        선택  하였는지  체크,  (default  :  2개만  가능)  
                *        if(!FForm(new  FCheck("체크박스"  ,  "checkboxTest")  
                *                        .setMulti(true).range(2).validation()))  return;  
                *        ==========================  사용법  ===================================================  
                *  
                *  FSelect  
                *        validation()        셀렉트  선택  여부  체크  
                *  
                *        ==========================  사용법  ===================================================  
                *        if(!FForm(new  FSelect("셀렉트"  ,  "selectTest")  
                *                        .validation()))  return;  
                *        ==========================  사용법  ===================================================  
                *  
                *  FSsn                                간단한  주민  번호  유효성  체크(input  2개일  경우에만  사용)  
                *        validation()        2개의  input  폼에  최적화  되어  있다.  
                *                                        Null  체크  ,  Number  체크  ,  Range  체크(default)  
                *  
                *        ==========================  사용법  ===================================================  
                *        if(!FForm(new  FSsn("주민등록번호"  ,  "test1"  ,  "test2")  
                *                        .validation()))  return;  
                *        ==========================  사용법  ===================================================  
                *  
                *  FFile  
                *        isNull                        공백  체크  
                *        nullable                빈  값  허용  여부(nullable  이면  값이  없으면  통과,  있으면  체크한다.)  
                *                ====================================================  
                *                //  isNull  과  nullable은  같이  사용할수  없다.  
                *                ====================================================  
                *        extention                허용하는  확장자  체크  
                *                                                                @arguments  허용할  확장자  명  
                *        xExtension                허용하지  않는  확장자  체크  
                *                                                                @arguments  제한할  확장자  명  
                *        validation()  
                *  
                *        ==========================  사용법  ===================================================  
                *        if(!FForm(new  FFile("Files"  ,  "fileTest")  
                *                        .isNull().xExtension("js","html").validation()))  return;  
                *        ==========================  사용법  ===================================================  
                */  

                //============================================================================  
                //        Form  Checker  
                //============================================================================  
                function  FForm()  {  
                        this.result  =  false;  

                        if(arguments[0].length  >  0)  {  
                                this.rList  =  arguments[0];  

                                for(var  x=0;  x<this.rList.length;  x++)  {  
                                        message.alert(this.rList[x]);  
                                        this.result  =  false;  
                                        break;  
                                }  
                        }else  this.result  =  true;  

                        return  this.result;  
                }  

                //============================================================================  
                //        Text  checker  
                //============================================================================  
                function  FText()  {  

                        this.cnt  =  0;  
                        this.result  =  [];  
                          
                        this.isFNull  =  false;  

                        this.msg  =  arguments[0];  
                        this.obj  =  arguments[1].getObject();  

                        //this.isBlockDiv  =  false;  
                        this.useDIVs                                =  _fncUseDivs;  

                        this.isNull                                        =  _fncIsNull;  
                        this.nullable                                =  _fncNullable;  
                        this.isNumber                                =  _fncIsNumber;  
                        this.isAlphaNumeric                        =  _fncIsAlphaNumeric;  
                        this.isAlphabat                                =  _fncIsAlphabeat;  
                        this.isKorean                                =  _fncIsKorean;  
                        this.isKoreanNumeric                =  _fncIsKoreanNumeric  
                        this.limitSpcChar                        =  _fncSpecialChar;  
                        this.isChainChar                        =  _fncChainChar;  
                        this.isMail                                        =  _fncIsMail;  
                        this.isSsn                                        =  _fncIsSsn;  
                        this.range                                        =  _fncIsRange;  

                        this.isDuplication                        =  _fncDblString;  
                        this.deleteDblArray                        =  _fncDeleteDblArray;  

                        this.focus                                        =  fncUnValidation;  

                        this.validation                                =  _fncTextValidation;  

                        return  this;  
                }  

                function  _fncNullable()  {  
                        this.isFNull  =  true;  
                        return  this;  
                }  

                function  _fncTextValidation()  {  
                        return  this.result;  

                }  

                //============================================================================  
                //        Radio  checker  
                //============================================================================  
                function  FRadio()  {  
                        this.cnt  =  0;  
                        this.result  =  [];  

                        this.msg  =  arguments[0];  
                        this.obj  =  eval("document.all."+arguments[1]);  

                        this.validation                        =  _fncRadioValidation;                          
                }  

                function  _fncRadioValidation()  {  
                          
                        this.radioCnt  =  0;  

                        if(this.obj.length  >  1)  {  
                                for(var  x=0;  x<this.obj.length;  x++)  {  
                                        if(this.obj[x].checked)  {  
                                                this.radioCnt++;  
                                        }  
                                }  

                                if(this.radioCnt  <=  0)  {  
                                        this.result[this.cnt++]  =  
                                                message.get("MSG-0002"  ,  this.msg  +  josa(this.msg  ,"을를"));  
                                }  
                        }else  {  
                                if(!this.obj.checked)  {  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0002"  ,  this.msg  +  josa(this.msg  ,"을를"));  
                                }  
                        }  

                        return  this.result;  
                }  
                  
                //============================================================================  
                //        CheckBox  checker  
                //============================================================================  
                function  FCheck()  {  
                        this.isMulti  =  false;  
                          
                        this.isRange  =  false;  
                        this.multiRange  =  1;  

                        this.cnt  =  0;  
                        this.result  =  [];  

                        this.msg  =  arguments[0];  
                        this.obj  =  eval("document.all."+arguments[1]);  
                          
                        this.setMulti                        =  _fncSetMulti;  
                        this.range                                =  _fncSetMultiRange;  

                        this.validation                        =  _fncCheckBoxValidation;                  
                }  

                function  _fncSetMulti()  {  
                        this.isMulti  =  arguments[0];  
                        return  this;  
                }  

                function  _fncSetMultiRange()  {  
                        if(arguments[0]  ==  null)  
                                this.multiRange  =  1;  
                        else  {  
                                this.multiRange  =  arguments[0];  
                        }  

                        this.isRange  =  true;  
                        return  this;  
                }  

                function  _fncCheckBoxValidation()  {  
                        this.txtBoxCnt  =  0;  

                        if(this.obj.length  >  1)  {  
                                for(var  x=0;  x<this.obj.length;  x++)  {  
                                        if(this.obj[x].checked)  {  
                                                this.txtBoxCnt++;  
                                        }  
                                }  

                                if(this.isMulti  ==  true)  {  
                                        //선택  하지  않았다면  
                                        if(this.txtBoxCnt  <=  0)  {  
                                                this.result[this.cnt++]  =  
                                                                message.get("MSG-0002"  ,  this.msg  +  josa(this.msg  ,"을를"));  
                                        }else  {  
                                                if(this.isRange)  {  
                                                        if(this.obj.length)  {  
                                                                if(Number(this.multiRange)  >  this.obj.length)  {  
                                                                        this.result[this.cnt++]  =  
                                                                                        message.get("MSG-0014"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                                                                }else  if(this.txtBoxCnt  >  Number(this.multiRange))  {  
                                                                        this.result[this.cnt++]  =  
                                                                                        message.get("MSG-0013"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  this.multiRange);  
                                                                }  
                                                        }else  {  
                                                                if(this.multiRange  >  1)  {  
                                                                        this.result[this.cnt++]  =  
                                                                                        message.get("MSG-0014"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                                                                }  
                                                        }  
                                                }                                                  
                                        }  
                                }else  {  
                                        if(this.txtBoxCnt  <=  0)  {  
                                                this.result[this.cnt++]  =  
                                                                        message.get("MSG-0002"  ,  this.msg  +  josa(this.msg  ,"을를"));  
                                        }else  if(this.txtBoxCnt  >  1)  {  
                                                this.result[this.cnt++]  =  
                                                                        message.get("MSG-0003"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  "1");  
                                        }  
                                }  
                        }else  {  
                                if(!this.obj.checked)  {  
                                        this.result[this.cnt++]  =  
                                                                message.get("MSG-0002"  ,  this.msg  +  josa(this.msg  ,"을를"));  
                                }  
                        }  

                        return  this.result;  
                }  

                //============================================================================  
                //        SelectBox  checker  
                //============================================================================  
                function  FSelect()  {  
                        this.isMulti  =  false;  

                        this.cnt  =  0;  
                        this.result  =  [];  

                        this.msg  =  arguments[0];  
                        this.obj  =  arguments[1].getObject();  

                        this.focus                                        =  fncUnValidation;  
                          
                        this.validation                                =  _fncSelectValidation;  
                }  

                function  _fncSelectValidation()  {  
                        if(this.obj[this.obj.selectedIndex].value.length  <=  0)  {  
                                this.focus();  
                                this.result[this.cnt++]  =  
                                                        message.get("MSG-0005"  ,  this.msg  +  josa(this.msg  ,"을를"));                  
                        }  

                        return  this.result;  
                }  

                //============================================================================  
                //        Check  Utils  
                //============================================================================  
                /**  
                *  Null  checker  
                */  
                function  _fncIsNull()  {  
                          
                        if  (this.obj.value  ==  null  
                                        ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                this.focus();  
                                this.result[this.cnt++]  =  
                                                        message.get("MSG-0001"  ,  this.msg  +  josa(this.msg  ,"을를"));  
                        }  
                        return  this;  
                }  

                /**  
                *  Number  checker  
                */  
                function  _fncIsNumber()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  

                        if(isNaN(this.obj.value))  {  
                                this.focus();  
                                this.result[this.cnt++]  =  
                                                        message.get("MSG-0006"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                        }  

                        return  this;  
                }  

                /**  
                *  Korean,  Number  checker  
                */  
                function  _fncIsKoreanNumeric()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  

                        this.reg  =  /^[가-&#55203;0-9]*$/;  
                        if(!this.reg.test(this.obj.value))  {  
                                this.focus();  
                                this.result[this.cnt++]  =  
                                                        message.get("MSG-0021"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                        }  
                        return  this;  
                }  

                /**  
                *  Korean  checker  
                */  
                function  _fncIsKorean()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  

                        this.reg  =  /^[가-&#55203;]*$/;  
                        if(!this.reg.test(this.obj.value))  {  
                                this.focus();  
                                this.result[this.cnt++]  =  
                                                        message.get("MSG-0021"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                        }  
                        return  this;  
                }  

                /**  
                *  Number,  English  checker  
                */  
                function  _fncIsAlphaNumeric()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  

                        this.reg  =  /^[a-zA-Z0-9]+$/;  
                        if(!this.reg.test(this.obj.value))  {  
                                this.focus();  
                                this.result[this.cnt++]  =  
                                                        message.get("MSG-0007"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                        }  

                        return  this;  
                }  

                /**  
                *  English  checker  
                */  
                function  _fncIsAlphabeat()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  

                        this.reg  =  /^[a-zA-Z]+$/;  
                        if(!this.reg.test(this.obj.value))  {  
                                this.focus();  
                                this.result[this.cnt++]  =  
                                                        message.get("MSG-0018"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                        }  

                        return  this;  
                }  

                /**  
                *  Ssn  checker(주민  등록  번호)  
                */  
                function  _fncIsSsn()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  

                        //000000-0000000  의  형식으로  입력  받아야  한다.  
                        if  (isNaN(this.obj.value.replace(/-|\s+/g,  "")))  {  
                                this.result[this.cnt++]  =  
                                                        message.get("MSG-0008"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  "000000-0000000");  
                                this.focus();  
                        }  

                        this.year  =  this.obj.value.substring(0,  2);  
                        this.month  =  this.obj.value.substring(2,  4);  
                        this.day  =  this.obj.value.substring(4,  6);  
                        this.sex  =  this.obj.value.substring(13,  14);  

                        if  ((this.obj.value.length  !=  14  )  ||  
                                                (this.year  <  25  ||  this.month  <  1  ||  this.month  >  12  ||  this.day  <  1))  {  

                                this.result[this.cnt++]  =  message.get("MSG-0009"  ,  this.msg  +  josa(this.msg  ,"이가"));  
                                this.focus();  
                        }  

                        if  ((this.sex  !=  1  &&  this.sex  !=2  ))  {  
                                this.result[this.cnt++]  =  message.get("MSG-0009"  ,  this.msg  +  josa(this.msg  ,"이가"));  
                                this.focus();  
                        }  
                        return  this;  
                }  

                /**  
                *  Range  checker  
                */  
                function  _fncIsRange()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  

                        var  total  =  0;  
                        for(var  i=0;i<this.obj.value.length;  i++)  {  
                                var  a  =  this.obj.value.charAt(i);  
                                if(escape(a).length  >=  6)  {  
                                        total  =  total  +  2;  
                                }else  {  
                                        total  =  total  +  1;  
                                }  
                        }  

                        if(!(total  >=  arguments[0]  &&  total  <=  arguments[1]))  {  
                                this.focus();  
                                if(arguments[0]  ==  arguments[1])  {  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0010"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  arguments[0]);  
                                }else  {  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0011"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  arguments[0]  ,  arguments[1]);  
                                }  
                        }  
                        return  this;  
                }  

                /**  
                *  Mail  checker  
                */  
                function  _fncIsMail()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  
                        this.reg  =  new  RegExp("(^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*$)");  
                        if(!this.reg.test(this.obj.value))  {  
                                this.focus();  
                                this.result[this.cnt++]  =  message.get("MSG-0009"  ,  this.msg  +  josa(this.msg  ,"이가"));  
                        }  

                        return  this;  
                }  


                /**  
                *  중복  문자열  checker  
                */  
                function  _fncDblString()  {  

                        this.dobRst  =  [];  
                        this.temp  =  [];  
                          
                        this.dobCnt  =  0;  
                        this.allowCnt  =  arguments[0]==null?3:arguments[0];  

                        for(var  x=0;  x<this.obj.value.length;  x++)          {  
                                var  cnt  =  0;  
                                for(var  i=0;  i<this.obj.value.length;  i++)  {  
                                        if(this.obj.value.charAt(x)  ==  this.obj.value.charAt(i))  {  
                                                cnt++;  
                                        }  
                                }  

                                this.temp[this.dobCnt]  =  [];  
                                this.temp[this.dobCnt][0]  =  this.obj.value.charAt(x);  
                                this.temp[this.dobCnt][1]  =  cnt;  
                                this.dobCnt++;  
                        }  

                        this.dobRst  =  this.deleteDblArray(this.temp);  

                        for(var  x=0;  x<this.dobRst.length;  x++)  {  
                                if(Number(this.dobRst[x][1])  >  Number(this.allowCnt))  {  
                                        this.focus();  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0022"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  this.allowCnt);  
                                        break;  
                                }  
                        }  
                        return  this;  
                }  

                function  _fncDeleteDblArray()  {  
                        if(arguments.length  >  0)  {  
                                for(var  x=0;  x<arguments[0].length;  x++)  {  
                                var  checkDbl  =  0;  
                                        for(var  i=0;  i<arguments[0].length;  i++)  {  
                                                if(arguments[0][x][0]  !=  arguments[0][i][0])  {  
                                                        continue;  
                                                }else  {  
                                                        checkDbl++;  
                                                        if(checkDbl  >  1)  {  
                                                                spliced  =  arguments[0].splice(i  ,  1);  
                                                        }  
                                                }  
                                        }  
                                }  
                        }  
                        return  arguments[0];  
                }  

                /**  
                *  문자의  연속성  체크  
                *  1234  ,  abcd  ,  9876  
                */  
                function  _fncChainChar()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  
                  
                        this.chainCnt  =  4;  

                        for(var  x=0;  x<this.obj.value.length;  x++)  {  

                                this.args  =  this.obj.value.substring(x,(x+1));  
                                this.asciiCode  =  this.obj.value.charCodeAt(x);  
                                  
                                this.inc_chainStrAscii  =  
                                        String.fromCharCode(this.asciiCode,  this.asciiCode+1,  this.asciiCode+2,  this.asciiCode+3);  
                                this.dec_chainStrAscii  =  
                                        String.fromCharCode(this.asciiCode,  this.asciiCode-1,  this.asciiCode-2,  this.asciiCode-3);  
/*  
                                if(this.args  >=  this.chainCnt  ||  this.asciiCode  >=  this.obj.value.charCodeAt(1))  {  
                                        this.dec_chainStrAscii  =  
                                                String.fromCharCode(this.asciiCode,  this.asciiCode-1,  this.asciiCode-2,  this.asciiCode-3);  
                                }  
*/  
                                if  ((this.obj.value.substring(x,  (x+this.chainCnt))  ==  this.inc_chainStrAscii)  
                                                        ||  this.obj.value.substring(x,  (x-this.chainCnt))  ==  this.dec_chainStrAscii)  {  
                                        this.focus();  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0023"  ,  this.msg  +  josa(this.msg  ,"이가"));  
                                        break;  
                                }  
                        }  

                        return  this;  
                }  

                /**  
                *  특수문자  체크  
                */  
                function  _fncSpecialChar()  {  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this;  
                                }  
                        }  

                        this.a_char  =  "";  
                        if(arguments[0]  !=  null)  {//  
                                this.sp_char  =  0;  
                                this.ex_cnt  =  0;  
                                this.extention  =  [];  

                                //예외를  제외한  모든  특수  문자  제한  
                                for(var  x=0;  x<arguments.length;  x++)  {  
                                        this.a_char  +=  "["  +  arguments[x]  +  "]  ";  
                                }  

                                for(var  x=0;  x<this.obj.value.length;  x++)  {  
                                        var  ret  =  this.obj.value.charCodeAt(x);  
                                        if((ret  >=  33  &&  ret  <=  47)  ||  (ret  >=  58  &&  ret  <=  64)  ||  
                                                        (ret  >=  91  &&  ret  <=  96)  ||  (ret  >=  123  &&  ret  <=  126))  {  
                                                this.extention[this.ex_cnt++]  =  this.obj.value.charAt(x);  
                                        }  
                                }  

                                if(this.extention.length  >  0)  {  
                                        for(var  x=0;  x<this.extention.length;  x++)  {  
                                                for(var  i=0;  i<arguments.length;  i++)  {  
                                                        if(this.extention[x]  ==  arguments[i])  this.sp_char++;  
                                                }  
                                        }  
                                }  
                                  
                                if(this.sp_char  !=  this.extention.length)  {  
                                        this.focus();  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0020"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  this.a_char);                                                  
                                }  
                        }else  {//특수  문자  혀용  하지  않음  
                                this.reg  =  /^[a-zA-Z0-9ㄱ-&#55203;]+$/;  
                                  
                                if(!this.reg.test(this.obj.value))  {  
                                        this.focus();  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0019"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                                }  
                        }  
                        return  this;  
                }  


                //============================================================================  
                //        Ssn  checker(주민등록  번호)  
                //  
                //                2개의  input  폼에  최적화  되어  있다.  
                //                null  체크  ,  숫자  체크  ,  length  체크(default)  
                //============================================================================  
                function  FSsn()  {  
                        this.obj;  

                        this.cnt  =  0;  
                        this.tmp  =  "";  
                        this.result  =  [];  
                          
                        this.msg  =  arguments[0];  
                        this.ssn  =  [];  
                        if(arguments.length  <=  0)  return  this;  
                        else  {  
                                var  ocnt  =  0;  
                                for(var  x=1;  x<arguments.length;  x++)  {  
                                        this.ssn[ocnt++]  =  arguments[x];  
                                }  
                        }  
                          
                        this.focus                                        =  fncUnValidation;  
                        this.validation                                =  _fncSsnValidation;  

                        return  this;  
                }  

                function  _fncSsnValidation()  {  
                        this.valid  =  false;  

                        for(var  x=0;  x<this.ssn.length;  x++)  {  
                                  
                                this.obj  =  this.ssn[x].getObject();  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0001"  ,  this.msg  +  josa(this.msg  ,"을를"));  
                                        this.focus();  
                                        break;  

                                }else  if(isNaN(this.obj.value))  {  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0006"  ,  this.msg  +  josa(this.msg  ,"은는"));  
                                        this.focus();  
                                        break;  

                                }else  {  
                                        if(x  ==  0  &&  this.obj.value.length  !=  6)  {  
                                                this.result[this.cnt++]  =  
                                                                message.get("MSG-0010"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  6);  
                                                this.focus();  
                                                break;  

                                        }else  if(x  ==  1  &&  this.obj.value.length  !=  7)  {  
                                                this.result[this.cnt++]  =  
                                                                message.get("MSG-0010"  ,  this.msg  +  josa(this.msg  ,"은는")  ,  7);  
                                                this.focus();  
                                                break;  
                                        }  
                                        this.tmp  +=  (this.obj.value).trim();  
                                        this.valid  =  true;  
                                }  
                        }  
                          
                        if(this.valid)  {  
                                this.year  =  this.tmp.substring(0,  2);  
                                this.month  =  this.tmp.substring(2,  4);  
                                this.day  =  this.tmp.substring(4,  6);  
                                this.sex  =  this.tmp.substring(12,  13);  

                                if  ((this.tmp.length  !=  13  )  
                                                        ||  (this.year  <  25  ||  this.month  <  1  
                                                        ||  this.month  >  12  ||  this.day  <  1))  {  
                                        this.focus();  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0009"  ,  this.msg  +  josa(this.msg  ,"이가"));  
                                }  

                                if  ((this.sex  !=  1  &&  this.sex  !=  2))  {  
                                        this.focus();  
                                        this.result[this.cnt++]  =  
                                                        message.get("MSG-0009"  ,  this.msg  +  josa(this.msg  ,"이가"));  
                                }  
                        }  

                        return  this.result;  
                }  

                //============================================================================  
                //        File  checker  
                //============================================================================  
                function  FFile()  {  
                        this.cnt  =  0;  
                        this.result  =  [];  
                        this.exFiles  =  [];  
                          
                        this.isFNull  =  false;  

                        this.allow  =  false;  
                        this.xAllow  =  false;  
                  
                        this.msg  =  arguments[0];  
                        this.obj  =  arguments[1].getObject();  

                        this.getFileEx                                =  _fncFileExtention;  

                        this.isNull                                        =  _fncIsNull;  
                        this.nullable                                =  _fncNullable;  

                        this.extention                                =  _fncExtention;  
                        this.xExtension                                =  _fncXExtention;  
                        this.validation                                =  _fncFileValidation;  

                        this.focus                                        =  fncUnValidation;  

                        return  this;  
                }  

                function  _fncExtention()  {  
                        if(arguments.length  <=  0)  {  
                                this.result[this.cnt++]  =  message.get("MSG-0016");  
                                return  this;  
                        }  

                        this.allow  =  true;  

                        this.ocnt  =  0;  
                        for(var  x=0;  x<arguments.length;  x++)  {  
                                this.exFiles[this.ocnt]  =  arguments[x];  
                                this.ocnt++;  
                        }  

                        return  this;  
                }  

                function  _fncXExtention()  {  
                        if(arguments.length  <=  0)  {  
                                this.result[this.cnt++]  =  message.get("MSG-0015");  
                                return  this;  
                        }  
                        this.xAllow  =  true;  

                        this.ocnt  =  0;  
                        for(var  x=0;  x<arguments.length;  x++)  {  
                                this.exFiles[this.ocnt]  =  arguments[x];  
                                this.ocnt++;  
                                  
                        }  
                        return  this;  
                }  

                function  _fncFileValidation()  {  
                        this.same  =  false;  

                        if(this.isFNull)  {  
                                if  (this.obj.value  ==  null  
                                                ||  this.obj.value.replace(/  /gi,"")  ==  "")  {  
                                        return  this.result;  
                                }  
                        }  

                        if(this.exFiles.length  <=  0)  
                                return  this.result;                                  

                        this.ex  =  this.getFileEx(this.obj.value);  

                        if(this.allow)  {  
                                for(var  x=0;  x<this.exFiles.length;  x++)  {  
                                        if(this.ex  ==  this.exFiles[x])  {  
                                                this.same  =  true  
                                                break;  
                                        }  
                                }  
                                if(!this.same)  {  
                                        this.focus();  
                                        this.result[this.cnt++]  =  message.get("MSG-0017");  
                                }  
                        }  

                        if(this.xAllow)  {  
                                for(var  x=0;  x<this.exFiles.length;  x++)  {  
                                        if(this.ex  ==  this.exFiles[x])  {  
                                                this.same  =  true  
                                                break;  
                                        }  
                                }  
                                if(this.same)  {  
                                        this.focus();  
                                        this.result[this.cnt++]  =  message.get("MSG-0017");  
                                }  
                        }  
                        return  this.result;  
                }  

                function  _fncFileExtention()  {  
                        this.index  =  arguments[0].lastIndexOf(".");  
                        return  arguments[0].substring(this.index+1);  
                }  

                //============================================================================  
                //        Focus  |  Selected  
                //============================================================================  
                function  fncUnValidation()  {  

                        if(this.obj.type  !=  "hidden")  {  
                                this.obj.focus();  
                                if(this.obj.type  ==  "text"  ||  this.obj.type  ==  "textarea"  ||  
                                                this.obj.type  ==  "password"  ||  this.obj.type  ==  "file")  
                                        this.obj.select();  
                        }  

                        return  this;  
                }  

                /**  
                *  make  by  BlueSys(푸른공허)  
                *  |jb0077|@|empal|.|com|  에서  |를  제거  하세요.  
                *  Object  
                *  
                *  사용법  :  
                *  "input".getObject().innerHTML  =  "hi~";  
                *  @result  :  object  
                */  
                String.prototype.getObject  =  function()  {  
                        this.obj  =  "";  
                        try  {  
                                if(this  ==  null)  {  
                                        this.obj  =  "";  
                                }else  this.obj  =  this;  
                        }catch(e)  {  
                                this.obj  =  "";  
                        }  

                        try  {  
                                if(document.getElementById(this.obj))  {  
                                        return  document.getElementById(this.obj);  
                                }else  {  
                                        throw  "Object가  필요합니다.  [  "  +  this.obj  +  "  ]";  
                                }  
                        }catch(e)  {  
                                alert("Error  ::  "  +  e);  
                                return  false;  
                        }  
                }  

                //  좌우  공백없애는  함수  
                String.prototype.trim  =  function  ()  {  
                        return  this.replace(/(^s*)|(s*$)/g,  "");  
                }  

                /**  
                *  주민등록  번호  작성시  
                *  <input  type="text"  onKeyUp="fncSsnForm(this);">  
                */  
                function  fncSsnForm()  {  
                        if(arguments[0].value.length  ==  6)  {  
                                arguments[0].value  =  arguments[0].value  +  "-";  
                        }  
                }
[본문링크] 폼체크임당
[1]
코멘트(이글의 트랙백 주소:/cafe/tb_receive.php?no=1155
작성자
비밀번호

 

SSISOCommunity

[이전]

Copyright byCopyright ⓒ2005, SSISO Community All Rights Reserved.